<template>
	<view>
<!-- 		<view class="header">
			<block v-for="item in navList" :key="item.id">
				<view class="item" :class="{'header-active':navId==item.id}" :data-id="item.id" @click="chooseNav">
					{{item.title}}
				</view>
			</block>
		</view> -->

		<!-- 新手学堂 start -->
		<view class="xuetang" v-if="navId==1">
			<view class="item2" v-for="(item,index) in videoList" :key="index">
				<view class="video" @click="playFullScreen(item.videoPath)">
					<image :src="baseHttp+item.ban" style="overflow: hidden;"></image>
				</view>
				<view class="itemBottom">
					{{index+1}}、{{item.title}}
				</view>
			</view>
		</view>
		<!-- 新手学堂 end -->
		<!-- 短视频案例 start -->
		<view class="duanshipin" v-if="navId==2">
			<view class="nav">
				<block v-for="(item,index) in TitleList" :key="index">
					<view class="nav-item" @click="changeItem(item)">
						<view class="content" :style="{ color: item.id === changeId ? 'white' : 'black' }">{{item.title}}</view>
					</view>
				</block>

			</view>
			<view class="duanshipin-content">
				<block v-for="(item,index) in shortVideoList" :key="index">
					<view class="item">
						<image :src="baseHttp+item.mian"  @click="playFullScreen(item.videoPath)" style="overflow: hidden;"></image>
						<view class="footer">
							<image src="../../static/icon/play.png" style="height: 30rpx;width: 30rpx"></image>
							<text style="font-size: 28rpx;margin-left: 10rpx;">13.8万播放量</text>
						</view>
					</view>
				</block>
			</view>

		</view>
		<!-- 新手学堂 end -->
		<!-- 直播间案例 start -->
		<view class="duanshipin" v-if="navId==3">
			<view class="nav">
				<block v-for="(item,index) in TitleList" :key="index">
					<view class="nav-item" @click="changeItem2(item)">
						<view class="content" :style="{ color: item.id === changeId2 ? 'white' : 'black' }">{{item.title}}</view>
					</view>
				</block>

			</view>
			<view class="duanshipin-content">
				<block v-for="(item,index) in zhiBoList" :key="index">
					<view class="item">
						<image :src="baseHttp+item.videoMain"  @click="playFullScreen(item.videoPath)" style="overflow: hidden;"></image>
						<view class="footer">
							<image src="../../static/icon/play.png" style="height: 30rpx;width: 30rpx"></image>
							<text style="font-size: 28rpx;margin-left: 10rpx;">13.8万播放量</text>
						</view>
					</view>
				</block>
			</view>

		</view>
		<!-- 直播间案例 end -->
	</view>
</template>

<script>
	import Http from '../../utils/http';
		var http = new Http()
	export default {
		data() {
			return {
				navList: [{
						id: 1,
						title: "新手学堂"
					},
					{
						id: 2,
						title: "短视频案例"
					},
					{
						id: 3,
						title: "直播间案例"
					}
				],
				navId: '',
				videoList: [],
				TitleList:[],
				shortVideoList:[],
				zhiBoList:[],
				changeId:1,
				changeId2:1,
				navId:1,
				baseHttp:''
			}
		},
		onLoad(option) {
			this.navId = option.type;
			if (this.navId == 1) {
				this.getNewClass();
				uni.setNavigationBarTitle({
					title: '新手教程',
				})
			} else if (this.navId == 2) {
				this.getShortVide();
				uni.setNavigationBarTitle({
					title: '短视频案例',
				})
			} else if (this.navId == 3) {
				this.getZhiBo();
				uni.setNavigationBarTitle({
					title: '直播案例',
				})
			}
		},
		mounted() {
			const app = getApp()
			this.baseHttp = app.globalData.baseHttp; // 输出 '我是全局变量'
		},
		methods: {
			changeItem2(data){
				this.changeId2 = data.id;
				http.get('v1/system/zhibo/'+this.changeId2).then(res=>{
					this.zhiBoList = res.data.data;
				})
			},
			//点击了标题
			changeItem(data){
				//http://localhost:8080/v1/system/shortVideo/id'+this.changeId2
				this.changeId = data.id;
				//'http://localhost:8080/v1/system/shortVideo/'+this.changeId2
				http.get('v1/system/shortVideo/'+this.changeId).then(res=>{
					console.log(res);
					this.shortVideoList = res.data.data;
				})			
			},
			async getNewClass(){
				http.get("v1/system/class/list").then(res=>{
					this.videoList = res.data.data;
				})
			
			},
			getNewClass(){
				http.get('v1/system/class/list').then(res=>{
					this.videoList = res.data.data;
				})	
			},
			getShortVide(){
				http.get('v1/system/titleList/list').then(res=>{
					this.TitleList = res.data.data
				})
				http.get('v1/system/shortVideo/'+this.changeId).then(res=>{
					this.shortVideoList = res.data.data
					console.log('食醋胡了');
					console.log(this.videoList);
				})
				
			},
			getZhiBo(){
				http.get('v1/system/titleList/list').then(res=>{
					this.TitleList = res.data.data
				})
				http.get('v1/system/zhibo/'+this.changeId).then(res=>{
					this.zhiBoList = res.data.data
				})
			},
			chooseNav(e) {
				// console.log(e.currentTarget.dataset.id);
				this.navId = e.currentTarget.dataset.id
				if(this.navId == 1){
					this.getNewClass();
					uni.setNavigationBarTitle({
						title: '新手教程',
					})
				}else if(this.navId == 2){
					this.getShortVide();
					uni.setNavigationBarTitle({
						title: '短视频案例',
					})
				}else if(this.navId == 3){
					this.getZhiBo();
					uni.setNavigationBarTitle({
						title: '直播案例',
					})
				}
			},
			playFullScreen(videoPath) {
				this.videoPath = this.baseHttp + videoPath;
				uni.navigateTo({
					url: '/subpkg/bopage/classbo?videoPath=' + this.videoPath
				});
			},
		}
	}
</script>

<style scoped lang="scss">
	page {
		background: #f1f1f1;
		width: 100%;
		height: 100%;
	}

	.header {
		height: 80rpx;
		background: #ffffff;
		width: 100%;
		display: flex;
		justify-content: space-between;
		border-bottom: 1rpx solid #eee;
		position: fixed;
		top: 0;
		right: 0;
		left: 0;
		z-index: 99;

		.item {
			height: 74rpx;
			line-height: 74rpx;
			font-size: 32rpx;
			color: #333333;
			// border-bottom: 6rpx solid #ffffff;
		}

		.item:nth-child(1) {
			margin-left: 6%;
		}

		.item:nth-child(3) {
			margin-right: 6%;
		}
	}

	.xuetang {
		margin-top:20rpx;
		padding: 0 30rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		.item2 {
			height: 500rpx;
			background-color: antiquewhite;
			width: 47%;
			border-radius: 20rpx;
			margin-bottom: 100rpx;
			display: flex;
			position: relative;
		
			.video {
				height: 500rpx;
				width: 100%;
				image {
					border-top-left-radius: 10rpx;
					border-top-right-radius: 10rpx;
					height: 445rpx;
					width: 100%;
				}
			}
		
			.itemBottom {
				z-index: 999;
				position: absolute;
				height: 60rpx;
				width: 100%;
				background-color: rgb(1, 152, 213);
				bottom: 0;
				border-bottom-left-radius: 20rpx;
				border-bottom-right-radius: 20rpx;
				line-height: 60rpx;
				color: white;
				font-size: 27rpx;
				text-align: center;
			}
		}
	}

	.duanshipin {
		margin-top: 30rpx;
		width: 100%;

		.nav {
			width: 100%;
			display: flex;
			flex-wrap: wrap;

			.nav-item {
				width: 25%;
				height: 60rpx;
				line-height: 60rpx;
				font-size: 28rpx;
				color: #333333;
				display: flex;
				justify-content: center;
				align-items: center;
				margin-bottom: 20rpx;
				

				.content {
					background: rgb(1, 152, 213);
					padding: 2rpx 18rpx;
					color: #fff;
					border-radius: 30rpx;
				}
			}
		}

		.duanshipin-content {
			// width: 100%;
			margin: 0 30rpx;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.item {
				width: 46%;
				height: 500rpx;
				border-radius: 10rpx;
				overflow: hidden;
				margin-bottom: 30rpx;
				position: relative;

				.img {
					height: 500rpx;
					width: 100%;
					display: block;
				}

				.footer {
					position: absolute;
					bottom: 0;
					left: 0;
					right: 0;
					height: 60rpx;
					background: rgb(1, 152, 213);
					font-size: 28rpx;
					padding: 0 10rpx;
					border-bottom-right-radius: 15rpx;
					border-bottom-left-radius: 15rpx;
					color: #fff;
					display: flex;
					align-items: center;
				}
			}
		}
	}

	.header-active {
		border-bottom: 6rpx solid #00008B;
		font-size: 36rpx;
	}
</style>